#!/bin/bash
path="/home/melonli/exp/bin2"
old_hour=-1
while [[ 1 ]]
do
    hour=`date +%H`
    if [[ $hour -gt $((old_hour)) ]]; then
        echo $hour >$path"/hour.txt"
        sudo salt "*" cmd.run "cd $path;echo $hour > hour.txt"
        if [[ $hour -lt 7 ]]; then
            sudo salt -N group1  cmd.run "cd $path;ipv6tun start;bash sinet_init 7"
            sudo salt -N group2  cmd.run "cd $path;ipv6tun start;bash sinet_init 6"
            sudo salt -N group3 cmd.run  "cd $path;ipv6tun start;bash sinet_init 3"
            #sudo salt "*" cmd.run "cd $path;bash sinet_init 6; bash monitorcpud"
        else
            sudo salt -N group1 cmd.run "cd $path;ipv6tun start;bash sinet_init 6"
            sudo salt -N group2 cmd.run "cd $path;ipv6tun start;bash sinet_init 5"
            sudo salt -N group3 cmd.run "cd $path;ipv6tun start;bash sinet_init 3"
            #sudo salt "*" cmd.run "cd $path;bash sinet_init 6; bash monitorcpud"
        fi
    fi
    old_hour=$hour
    sleep 100
done
